/***************************************************************************
 创建者: 华磊
 开始时间: 2018.8.14
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2017.5.8 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *                                                                         *
 ***************************************************************************/
#ifndef PALINSTRUCTIONLOGIC_H
#define PALINSTRUCTIONLOGIC_H
#include "palinstruction.h"
#include "programset.h"
#include "instructionEnum.h"
#include "robotio.h"
#include "mccontrollerthread.h"
#include <QStack>

class PalletCalculate;
class ProgramEngine;
/**
 * @brief The PalInstructionLogic class   指令逻辑处理类
 */
class PalInstructionLogic
{
public:
    PalInstructionLogic(int robotIdIn, RegData *regDataIn, RobotIo* ioControllerIn,
                        ProgramEngine* programEngineIn, McControllerThread *programMcControllerIn
                        ,QString configPathIn);

public:
    /**
     * @brief startPal              码垛指令Ｂ、Ｂｘ、Ｅ、Ｅｘ、Ｅｎｄ
     * @param programNum            程序号码
     * @return
     */
    E_PROGRAM_LOOP_RESULT startPallet(int programNum,PalInstruction palInstruct);

    int getPalletConditionInfo(std::vector<struct PalletMiddleInfo> &infoOut);
    int setPalletConditionInfo(struct StackInfo infoIn);


    /**
     * @brief parsePLData           解析PL指令，最后返回【i、j、k】
     * @return                      返回【i、j、k】
     */
    QVector <int> parsePLData(int programNum);
    /**
     * @brief parsePRData           解析PR指令，最后返回PR的值
     * @return
     */
    PointPro parsePRData(int programNum);

    /**
     * @brief parseRegisterData     解析发送过来的QVector类型的数据集合
     * @return
     */
    float parseRegisterData(int programNum);


private:

    /**
     * @brief addMsg  , 添加消息反馈
     * @param messageLevel
     * @param componentName
     * @param messageType
     * @param messageCode
     * @param robotId
     * @param parameter1
     * @param parameter2
     * @param parameter3
     * @param parameter4
     */
    void addMsg( int messageLevel,
                 std::string componentName,
                 std::string messageType,
                 int messageCode,
                 int robotId,
                 int parameter1 = 0,
                 int parameter2 = 0,
                 int parameter3 = 0,
                 int parameter4 = 0,
                 QString message= "");

private:
    int robotId;
    RegData *regData;
    RobotIo* ioController;
    ProgramEngine* programEngine;


    /**
     * @brief programMcController       算法线程指针
     */
    McControllerThread *programMcController;

    PalletCalculate *palCalculate;




};

#endif // PALINSTRUCTIONLOGIC_H
